﻿
Namespace PL.CRMSDK
    Public Class OrderHeader_PL
        Inherits PLBase

        'Nos paramêtre pour controler si on génère les séquences ou non...
        Public aOrderNoSEQ As Boolean = True
        Public aInvoiceNoSEQ As Boolean = False

        Public Sub New()
            MyBase.New()
        End Sub

        Public Sub New(ByVal queryName As String)
            MyBase.New(queryName)
        End Sub

        ''' <summary>
        ''' Cette procedure est appellé pour chaque ligne qui sera traité.
        ''' quand le Me.MetaDataTable.Adapter.Update() est appelé via ApplyChanges()
        ''' Si on veut faire de la logique sur les lignes il faut vérifier le 
        ''' DataRowState.Added, DataRowState.Modified etc...
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <param name="e"></param>
        ''' <remarks></remarks>
        Sub OnRowUpdating(ByVal sender As Object, ByVal e As SqlRowUpdatingEventArgs) Handles MetaDataTable.OnRowUpdating
            If e.Row.Table.TableName = "OrderHeader" Then

                'Pour le Save sur un ADD on assign la sequence
                Me.MetaDataTable.Adapter.InsertCommand.Parameters("@OrderNoSEQ").Value = aOrderNoSEQ
                Me.MetaDataTable.Adapter.InsertCommand.Parameters("@InvoiceNoSEQ").Value = aInvoiceNoSEQ
                '
                Me.MetaDataTable.Adapter.UpdateCommand.Parameters("@OrderNoSEQ").Value = aOrderNoSEQ
                Me.MetaDataTable.Adapter.UpdateCommand.Parameters("@InvoiceNoSEQ").Value = aInvoiceNoSEQ

            End If
        End Sub

        Public Overrides Function Delete() As Boolean
            'Throw New NotImplementedException("Delete To Come...")
            Return False
        End Function

        Public Overrides Function Validate() As Boolean
            'Throw New NotImplementedException("Validate To Come...")
            Return True
        End Function
    End Class
End Namespace
